﻿//=======================================================
// Author: Jonas Follesø <jonas@follesoe.no>
// Copyright (c) 2008
//
// Licensed under the Microsoft Public License (Ms-PL)
// A copy of the license is available at 
// http://www.opensource.org/licenses/ms-pl.html
//=======================================================

using System;
using System.Text;
using System.Windows;

namespace Colorful.Control.Services
{
    public class XamlTextClipboardFormatter : ICopyColors
    {
        public string FormatName
        {
            get { return "Text"; }
        }

        public void AddToClipboard(DataObject dataObject, Palette palette)
        {
            string name = palette.Name.Replace(" ", "").Trim();

            var builder = new StringBuilder();
            builder.AppendFormat("<SolidColorBrush x:Key=\"{0}Color1\" Color=\"{1}\" />\r\n", name, palette.Color1);
            builder.AppendFormat("<SolidColorBrush x:Key=\"{0}Color2\" Color=\"{1}\" />\r\n", name, palette.Color2);
            builder.AppendFormat("<SolidColorBrush x:Key=\"{0}Color3\" Color=\"{1}\" />\r\n", name, palette.Color3);
            builder.AppendFormat("<SolidColorBrush x:Key=\"{0}Color4\" Color=\"{1}\" />\r\n", name, palette.Color4);
            builder.AppendFormat("<SolidColorBrush x:Key=\"{0}Color5\" Color=\"{1}\" />\r\n", name, palette.Color5);
            dataObject.SetText(builder.ToString());
        }
    }
}
